# coding=utf-8
##
## Author: jmdvirus@aliyun.com
##
## Create: 2018年08月16日 星期四 15时13分07秒
##

from io import BytesIO
from PIL import Image, ImageOps
import numpy as np
import requests

from graphpipe import remote

class GPBaseFunc():
    def base_call(self, file):
        data = np.array(Image.open(file))
        data = data.reshape([1] + list(data.shape))
        data = np.rollaxis(data, 3, 1).astype(np.float32)  # channels first
        print(data.shape)

        pred = remote.execute("http://127.0.0.1:9000", data)
        print("Expected 504 (Coffee mug), got: %s" % np.argmax(pred, axis=1))

